package com.idealighter.game.web.checklevel.fqzs.controller.convert;

import com.idealighter.game.web.checklevel.fqzs.controller.dto.FqzsCheckResultDto;
import com.idealighter.game.web.checklevel.fqzs.service.bo.FqzsCheckResultBo;
import com.idealighter.game.web.checklevel.shuihu.service.ShuiHuBasicControlCheck.IdCount;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public abstract class FqzsCheckResultDtoConvert {
  public static final FqzsCheckResultDtoConvert INSTANCE =
      Mappers.getMapper(FqzsCheckResultDtoConvert.class);

  /**
   * bo转dto.
   * 
   * @Title bo2dto.
   * @date 2018年1月12日 下午5:48:27
   * @param bo bo对象
   * @return Dto
   */
  public FqzsCheckResultDto bo2dto(FqzsCheckResultBo bo) {
    FqzsCheckResultDto result = null;
    if (bo != null) {
      result = new FqzsCheckResultDto();
      result.setBetChips(bo.getBetChips());
      result.setWinChips(bo.getWinChips());
      result.setRewarList(toRewardList(bo.getRewardMap()));
      result.setIconCountList(toIconCountList(bo.getIconCountMap()));
    }
    return result;
  }

  /**
   * 转换成rewardList.
   * 
   * @Title toRewardList.
   */
  public List<IdCount> toRewardList(Map<Integer, Long> rewardMaps) {
    List<IdCount> list = new ArrayList<IdCount>();
    for (int id : rewardMaps.keySet()) {
      Long count = rewardMaps.get(id);
      IdCount item = new IdCount();
      item.setId(id);
      item.setCount(count);
      list.add(item);
    }
    return list;
  }

  /**
   * 转换成iconCountList.
   * 
   * @Title toIconCountList.
   */
  public List<IdCount> toIconCountList(Map<Integer, Integer> iconCountMap) {
    List<IdCount> list = new ArrayList<IdCount>();
    for (int id : iconCountMap.keySet()) {
      Long count = iconCountMap.get(id).longValue();
      IdCount item = new IdCount();
      item.setId(id);
      item.setCount(count);
      list.add(item);
    }
    return list;
  }
}
